package com.tigerhhzz.controller;

import com.tigerhhzz.service.SmsSenderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author tigerhhzz
 * @Date 2024 10 05 13 35
 **/
@RestController
@RequestMapping("/sms")
public class SmsController {

    @Autowired
    private SmsSenderService smsSenderService;

    /**
     * 通过mq发送短信验证码
     * @param phoneNumber
     */
    @RequestMapping(value="/sendsmsbymq/{phoneNumber}",method= RequestMethod.POST)
    public String sendCode(@PathVariable String phoneNumber ){
        smsSenderService.sendSmsAsync(phoneNumber);
        System.out.println("手机号：" +phoneNumber+";发送短信验证码成功");
        return "短信发送任务已提交，将异步发送。";
    }
}
